package com.ruoyi.projects.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.projects.domain.SlQuestions;
import com.ruoyi.projects.service.ISlQuestionsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 客服智能问题Controller
 * 
 * @author yangz
 * @date 2024-12-01
 */
@RestController
@RequestMapping("/projects/SlQuestions")
public class SlQuestionsController extends BaseController
{
    @Autowired
    private ISlQuestionsService slQuestionsService;

    /**
     * 查询客服智能问题列表
     */
    @PreAuthorize("@ss.hasPermi('projects:SlQuestions:list')")
    @GetMapping("/list")
    public TableDataInfo list(SlQuestions slQuestions)
    {
        startPage();
        List<SlQuestions> list = slQuestionsService.selectSlQuestionsList(slQuestions);
        return getDataTable(list);
    }

    /**
     * 导出客服智能问题列表
     */
    @PreAuthorize("@ss.hasPermi('projects:SlQuestions:export')")
    @Log(title = "客服智能问题", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SlQuestions slQuestions)
    {
        List<SlQuestions> list = slQuestionsService.selectSlQuestionsList(slQuestions);
        ExcelUtil<SlQuestions> util = new ExcelUtil<SlQuestions>(SlQuestions.class);
        util.exportExcel(response, list, "客服智能问题数据");
    }

    /**
     * 获取客服智能问题详细信息
     */
    @PreAuthorize("@ss.hasPermi('projects:SlQuestions:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(slQuestionsService.selectSlQuestionsById(id));
    }

    /**
     * 新增客服智能问题
     */
    @PreAuthorize("@ss.hasPermi('projects:SlQuestions:add')")
    @Log(title = "客服智能问题", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SlQuestions slQuestions)
    {
        return toAjax(slQuestionsService.insertSlQuestions(slQuestions));
    }

    /**
     * 修改客服智能问题
     */
    @PreAuthorize("@ss.hasPermi('projects:SlQuestions:edit')")
    @Log(title = "客服智能问题", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SlQuestions slQuestions)
    {
        return toAjax(slQuestionsService.updateSlQuestions(slQuestions));
    }

    /**
     * 删除客服智能问题
     */
    @PreAuthorize("@ss.hasPermi('projects:SlQuestions:remove')")
    @Log(title = "客服智能问题", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(slQuestionsService.deleteSlQuestionsByIds(ids));
    }
}
